#include "threewidget.h"

ThreeWidget::ThreeWidget(QWidget *parent,const char *name):QWidget(parent)
{
    counter = 0;
    QTextCodec *textcodec = QTextCodec::codecForName("utf-8");//设置字符编码

    QTextCodec::setCodecForCStrings(textcodec);
    QTextCodec::setCodecForLocale(textcodec);
    QTextCodec::setCodecForTr(textcodec);

                setMinimumSize(400,180);
                setMaximumSize(400,180);
		button1 = new QPushButton("Top Button",this);
                button1->setGeometry(15,15,200,40);

		label1 = new QLabel("Middle Label",this);
                label1->setGeometry(15,70,200,40);
		label1->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
		button2 = new QPushButton("Bottom Button",this);
                button2->setGeometry(15,125,90,40);

                setWindowTitle("标题栏");

                QObject::connect(button1, SIGNAL(clicked()), this, SLOT(close()));
                QObject::connect(button2, SIGNAL(clicked()), this, SLOT(Increment()));
}

void ThreeWidget::Increment()
{
    QString qstring = QString::number(counter);
    label1->setText(qstring);
    counter++;
}

